<template>
	<view class="p-2 bg-white h_100">
		<view class="font-weight-bolder text-center">
			<text class="h4">{{ info.product_name }}</text>
			<!-- <view class="select_box flex mt-2">
				<text class="tit h6 c_6 px-1 text_hidden1">{{ info.product_model }}</text>
			</view> -->
		</view>
		<view class="mt-4">
			<text class="h4 font-weight-bolder">发送请求给：</text>
			<view class="text-center h4 py-1">{{ info.company_name }}</view>
		</view>
		<view class="mt-4">
			<text class="h4 font-weight-bolder">您的联系信息：</text>
			<view class="">
				<view class="info_row py-1">
					<text class="label" style="letter-spacing:25px">姓名</text>
					<text class="h4">{{ info.sign_name }}</text>
				</view>
				<view class="info_row py-1">
					<text class="label">公司名称</text>
					<text class="h4 ml-5">{{ info.sign_company }}</text>
				</view>
				<view class="info_row py-1">
					<text class="label">电子邮件</text>
					<text class="h4 ml-5">{{ info.sign_email }}</text>
				</view>
				<view class="info_row py-1">
					<text class="label" style="letter-spacing:25px">电话</text>
					<text class="h4">{{ info.sign_phone }}</text>
				</view>
				<view class="info_row py-1">
					<text class="label" style="letter-spacing:25px">QQ</text>
					<text class="h4">{{ info.sign_qq }}</text>
				</view>
				<view class="info_row py-1">
					<text class="label" style="letter-spacing:25px">地区</text>
					<text class="h4">{{ info.sign_address }}</text>
				</view>
			</view>
		</view>
		<view class="mt-4">
			<text class="h4 font-weight-bolder">附加评论（请附上潜在购买数量）：</text>
			<view class="h4">{{ info.content }}</view>
		</view>
		<view class="cont_box">
			<button class="reply_btn h4 text-white font-weight-bolder mt-3">企业回复</button>
			<!-- info.is_type == 2 已回复 -->
			<view class="mt-3">
				<textarea class="reply_cont" v-model="info.reply_content" :placeholder="info.is_reply == 1? '请输入回复内容' : '请等待对方回复...'" :disabled="info.is_reply == 0" />
			</view>
		</view>
		<!-- is_reply 0未回复 1已回复 -->
		<button v-if="info.is_reply == 1" class="b_btn bg_main h4 text-white font-weight-bolder mt-3 rounded-0" @click="reply">确认回复</button>
	</view>
</template>

<script>
import { getWapAdvisoryInfo, replyUpdate } from '@/api/my/enquiry.js';
export default {
	data() {
		return {
			info: {},
			btnShow: true
		};
	},
	onLoad(option) {
		// this.btnShow = option.ismy == 'true' ? true : false;
		// console.log('个人中心', this.btnShow, typeof this.btnShow);
		this.getInfo(option.id);
		// 分享
		wx.showShareMenu({
			withShareTicket: true,
			menus: ['shareAppMessage', 'shareTimeline']
		});
	},
	methods: {
		getInfo(val) {
			getWapAdvisoryInfo({ id: val })
				.then(res => {
					// console.log(res);
					if (res.code == 0) {
						this.info = res.data;
						// 企业uid如果和登录的用户uid一致则不能回复
						// this.info.uid == uni.getStorageSync('userInfo').userId ||
						if (this.info.is_type === 2) {
							this.btnShow = false;
						}
					} else {
						uni.$u.toast(res.msg);
					}
				})
				.catch(err => {
					console.log('获取询价详情失败', err);
				});
		},
		reply() {
			if (!this.info.reply_content) {
				uni.$u.toast('请输入回复内容');
			} else {
				let msg = {
					id: this.info.id,
					reply_content: this.info.reply_content
				};
				replyUpdate(msg)
					.then(res => {
						// console.log(res);
						uni.$u.toast(res.msg);
						if (res.code == 0) {
							this.btnShow = false;
						}
					})
					.catch(err => {
						console.log('获取询价详情失败', err);
					});
			}
		}
	}
};
</script>

<style lang="scss" scoped>
.select_box {
	width: 100%;
	height: 56rpx;
	background-color: #ededed;
	text-align: center;
	line-height: 56rpx;
	position: relative;
	.tit {
		width: calc(100% - 50rpx);
		line-height: 56rpx;
	}
}
.info_row {
	font-size: 26rpx;
}
.reply_btn {
	width: 100%;
	height: 66rpx;
	background-color: $color14;
	line-height: 66rpx;
}
.reply_cont {
	width: 100%;
	height: 220rpx;
	background: #ededed;
	padding: 20rpx;
	font-size: 32rpx;
	font-weight: 800;
	color: #666666;
	line-height: 42px;
}
.cont_box {
	margin-bottom: 150rpx;
}
.b_btn {
	width: 100%;
	height: 98rpx;
	line-height: 98rpx;
	position: fixed;
	bottom: 0;
	left: 0;
}
</style>
